package com.github.sparkzxl.demo.domain.service;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.json.JSONUtil;
import com.github.javafaker.Faker;
import com.github.sparkzxl.database.entity.RemoteData;
import com.github.sparkzxl.demo.application.service.IUserService;
import com.github.sparkzxl.demo.infrastructure.entity.UserBasicInfo;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Locale;

/**
 * description: 用户 服务实现类
 *
 * @author charles.zhou
 * @date 2021-05-06 13:55:28
 */
@Service
public class UserServiceImpl implements IUserService {

    @Override
    public List<UserBasicInfo> findUserBasicInfoList() {
        List<UserBasicInfo> userBasicInfos = Lists.newArrayList();
        Snowflake snowflake = IdUtil.getSnowflake(0, 10);
        Faker faker = new Faker(Locale.CHINA);
        for (int i = 0; i < 10; i++) {
            UserBasicInfo userInfo = new UserBasicInfo();
            userInfo.setId(snowflake.nextId());
            String name = faker.name().fullName();
            userInfo.setName(name);
            String pinyin = StringUtils.deleteWhitespace(PinyinUtil.getPinyin(name));
            userInfo.setAccount(pinyin);
            userBasicInfos.add(userInfo);
        }
        return userBasicInfos;
    }
}
